import { Navigate, Outlet } from 'umi';
import { getToken } from '@/utils/authInterceptor';

export default () => {
  // 检查是否有管理员token来判断用户是否已登录
  const token = getToken();
  const isLogin = !!token;

  if (isLogin) {
    return <Outlet />;
  } else {
    return <Navigate to="/login" replace />;
  }
};
